package com.tiancheng.trade.settlement.util;

import cn.dev33.satoken.stp.StpUtil;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils;

@Slf4j
public class UserUtils {

    private UserUtils() {
    }

    /**
     * 获取当前用户id
     *
     * @return
     */
    public static String currentUserId() {
        final Object profile = StpUtil.getLoginId();
        if (profile == null || StringUtils.isBlank(profile.toString())) {
            return "system";
        }
        return profile.toString();
    }

    /**
     * 获取当前用户name
     *
     * @return
     */
    public static String currentUserName() {

        String current = "system";
/*
        final Object profile = StpUtil.getLoginId();
        if (profile == null || StringUtils.isBlank(profile.toString())) {
            return current;
        }
        Object name = profile.getAttribute("name");

        if (name == null) {
            return current;
        }
        current = name.toString();

        log.info("currentUserName:", current);
*/

        return String.valueOf(current);
    }
}
